﻿#include <QCoreApplication>
#include <Ice/Ice.h>
#include <smart_senser_slice_api.h>
#include <QDebug>

using namespace desig::slice_api;

// 实现Client接口
class ClientI : public desig::slice_api::Client {
public:
    ClientI(){

    };
    // 已经实现的方法保持不变
    virtual void OnConnect(const Ice::Current&) override {
        std::cout << "Client connected." << std::endl;
    }
};


int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    try {
        Ice::InitializationData id;
        Ice::CommunicatorHolder ich(argc, argv, id);

        // 创建对象适配器并绑定到特定端口
        Ice::ObjectAdapterPtr adapter = ich->createObjectAdapterWithEndpoints("ClientAdapter", "default -p 10000");


        // 将实现类添加到适配器中
        adapter->add(new ClientI(), Ice::stringToIdentity("client"));

        // 激活适配器
        adapter->activate();

        // 等待关闭信号
        ich->waitForShutdown();
    } catch (const std::exception& ex) {
        std::cerr << ex.what() << std::endl;
    }
    return a.exec();
}

